﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Text;
using System.Web.UI.WebControls;
using CNVP.JShop.UI;
using CNVP.Framework.Utils;
using CNVP.JShop.BLL;

namespace CNVP.JShop.Admin.Template
{
    public partial class OpenUnitSetting : System.Web.UI.Page
    {
        public string TemplateUrl = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!BLL.BLLCheckAdmin.LoginOk(Page, 102) || !BLL.BLLCheckAdmin.LoginOk(Page, 118) || !BLL.BLLCheckAdmin.LoginOk(Page, 119)) return;//判断页面权限
            if (!IsPostBack)
            {
                string _UnitID = Request.Params["UnitID"];
                string _StyleID = Request.Params["TemplateID"];
                string _ModuleType = Request.Params["ModuleType"];
                string unitStyleID=Request.Params["StyleID"];
                if (string.IsNullOrEmpty(_UnitID) || (!Public.IsNumber(_UnitID)))
                {
                    _UnitID = "0";
                }
                if (string.IsNullOrEmpty(_StyleID) || (!Public.IsNumber(_StyleID)))
                {
                    _StyleID = "0";
                }
                if (string.IsNullOrEmpty(_ModuleType) || (!Public.IsNumber(_ModuleType)))
                {
                    _ModuleType = "0";
                }
                LitUnitName.Text = Request.Params["UnitName"];
                #region "样式选择下拉框"
                CNVP.JShop.BLL.CNVP_UnitsInfo bll = new CNVP.JShop.BLL.CNVP_UnitsInfo();
                DataTable Dt1 = bll.GetUnitStyleProperty(_StyleID, _ModuleType);
                foreach (DataRow Row in Dt1.Rows)
                {
                    ListItem _List = new ListItem();
                    _List.Text = Row["ItemName"].ToString();
                    _List.Value = Row["ItemValue"].ToString();
                    if (Row["ItemValue"].ToString() == _StyleID)
                    {
                        _List.Selected = true;
                        TemplateUrl = Row["ItemUrl"].ToString() + "?UnitID=" + _UnitID + "&TemplateID=" + Row["ItemValue"].ToString() + "&StyleID=" + unitStyleID;
                    }
                    DropUnitType.Items.Add(_List);
                }
                DropUnitType.Attributes.Add("onChange", "ChangeUnitType(this," + _UnitID + ",document.form1.DropUnitType.options[document.form1.DropUnitType.selectedIndex].value)");
                #endregion
            }
        }
    }
}
